<h1>资源库存列表</h1>
<table class="easyui-datagrid list-table" style="width: 850px;height:auto;">
  <thead>
    <tr>
      <th field="id" width="50" align="center">ID</th>
      <th field="name" width="100" align="center">名称</th>
      <th field="category" width="100" align="center">资源类别</th>
      <th field="publish" width="110" align="left">出版社</th>
      <th field="price" width="50" align="center">定价</th>
      <th field="quantity" width="50" align="center">库存</th>
      <th field="operation" width="240" align="center">操作</th>
    </tr>
  </thead>
  <tbody>
    <% if @resources.empty? %>
      <tr>
        <td mergeCell=true colspan="6">暂无库存</td>
      </tr>
    <% else %>
      <% @resources.each do |resource| %>
        <tr>
          <td><%= resource.id %></td>
          <td><%= resource.name %></td>
          <td><%= resource.category.name %></td>
          <td>
            <% if resource.publish %>
              <%= resource.publish %>
            <% end %>
          </td>
          <td><%= resource.price %></td>
          <td><%= resource.quantity %></td>
          <td><%= link_to "删除", :action=>'destroy', :id=>resource %>  | <%= link_to "编辑", {:action => 'edit',:id=> resource}%> </td> 
        </tr>
      <% end %>
    <% end %>
  </tbody>
</table>
<%= link_to "添加新资源", :action=>'new' %>
